<!DOCTYPE html> 
<html>

<head>
  <title></title>
  
  
  
  <?php
      include_once('head.php'); 
   ?> 
  
  <!-- <script type="application/javascript" src="iscroll4/src/iscroll.js"></script> -->
  
  <link href="jquery-mobile-iscrollview-master/lib/jquery.mobile.iscrollview.css" media="screen" rel="stylesheet" type="text/css" />
  <link href="jquery-mobile-iscrollview-master/lib/jquery.mobile.iscrollview-pull.css" media="screen" rel="stylesheet" type="text/css" /> 
  
  <style>
  .block {
  padding: 0px;
  width: 50%;
  }
  #container {
  width: inherit !important;
  margin: 100%;
  }
  </style>
 
 <!--  for blocksit : pinterest effect -->
  
  <link rel='stylesheet' href="blocksit/style-custom.css" media='screen' />
  
  
  
<!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> -->

<script src="blocksit/blocksit.min.js"></script>
  
  
  
  
  <!-- css per il footer -->
  <style>
      .nav-glyphish-example .ui-btn .ui-btn-inner { height:25px; padding-top: 10px !important; }
      .nav-glyphish-example .ui-btn .ui-icon { width: 30px!important; /*height: 25px!important;*/ margin-left: -15px !important; box-shadow: none!important; -moz-box-shadow: none!important; -webkit-box-shadow: none!important; -webkit-border-radius: 0 !important; border-radius: 0 !important; }
      #home .ui-icon { background:  url(images/glyphish-icons-png/53-house.png) 50% 50% no-repeat; background-size: 18px 18px; }
      #search .ui-icon { background:  url(images/glyphish-icons-png/06-magnify.png) 50% 50% no-repeat; background-size: 18px 16px;  }
      #gift .ui-icon { background:  url(images/glyphish-icons-png/24-gift.png) 50% 50% no-repeat;  background-size: 14px 20px; }
      #wishlist .ui-icon { background:  url(images/glyphish-icons-png/28-star.png) 50% 50% no-repeat;  background-size: 22px 22px; }
   </style>
  
  
  <script type="application/javascript" src="jquery-mobile-iscrollview-master/demo/build/javascripts/iscroll.js"></script>
  <script type="application/javascript" src="jquery-mobile-iscrollview-master/lib/jquery.mobile.iscrollview.js"></script>
  <!-- <script type="application/javascript" src="jquery-mobile-iscrollview-master/demo/build/javascripts/pull-example.js"></script> -->
  
  
  
  
  
  
  
  
  <script type="text/javascript"> 



  
  	 function Gift(giftname, giftdest, giftbudget_min, giftbudget_max){
 	      this.name = giftname;
 	      this.dest = giftdest;
 	      this.budget_min = giftbudget_min;
 	      this.budget_max = giftbudget_max;  
 	  }

  	 function getFromSession() {
		return JSON.parse(sessionStorage.getItem('gift')); 
  	  	 }

  	 
  	function print() {
		var g = getFromSession();
		var s = 'Nome: ' + g.name + ' Destinatario: ' + g.dest + ' min: ' + g.budget_min + ' max: ' + g.budget_max; 
		alert(s);
		  }

  	
  	 function updateInSession() {
  		var gift = getFromSession();
  		gift.budget_min = $('#budget_min').val();
		  gift.budget_max = $('#budget_max').val();

		  //print();

  	  	
		  sessionStorage.setItem('gift', JSON.stringify(gift) );

		// print();
  	  	 }

  	
  	 
 	  function get_giftname() {
 	 	var gift = getFromSession();
 		return gift.name;
 		  } 

	  function get_giftdest() {
		 var gift = getFromSession();
		 return gift.dest;
		  }

	  function get_giftbudgetmin() {
			 var gift = getFromSession();
			 return gift.budget_min;
			  }

	  function get_giftbudgetmax() {
			 var gift = getFromSession();
			 //alert(gift.budget_max);
			 return gift.budget_max;
			  }  


	
	  	    
  	
  	
  	
  	
  	
  function load_data() {

	 

    
  }	

  
  $(document).ready(function(){ 
	  var div = '<div><h4>' + 'Regalo per ' + get_giftname() + '<h4></div>';    
	  $('div#show').html(div);	

	  $('#budget_min').val(get_giftbudgetmin());
	  $('#budget_max').val(get_giftbudgetmax()); 
	  $('#budget_range').rangeslider( "refresh" );  // refresh effetto grafico




	  /*
	  * Quando il panel viene chiuso devo salvare le modifiche.
	  * In alternativa posso aggiungere nel panel un button SAVE e
	  * agganciare l'evento di salvataggio.
	  */
	  $( "#optpanel" ).on( "panelclose", function( event, ui ) {
      //$('#thelist').empty();
			updateInSession();
			load_data();  // in this case refresh list
			
			$('#gifts_in_shake').css('visibility', 'visible');
			$('#gifts_in_shake').html('5');

	 	} );
	 	
	 	
	 	load_data();



	 	$('#container').BlocksIt({
   	      numOfCol: 2,
   	      offsetX: 8,
   	      offsetY: 8
   	    });

   	    
	 	$("#page_giftlist div[data-role=content]").iscrollview("refresh");
	 	
	 
    
    
	 
  });  // end document ready

 
  
  
  </script>
  
  
  <!-- To load Iscroll  -->
  
  <!-- <script type="text/javascript">
    
    var popular_scroll;
    var consigliati_scroll;
    function loaded() {
      popular_scroll = new iScroll('most_popular');
      //consigliati_scroll = new iScroll('consigliati');
    }
    
    // if set, block vertical scroll of the page
    //document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
    
    //document.addEventListener('DOMContentLoaded', loaded, false);
    
  </script> -->
  
  
  
  
  <style type="text/css">
  /*  
    .horizontalWrapper {
      height: 155px;
      
    }
   */ 
    /*.scroller li {
      font-size: 10px;
    }*/
    
  </style>
  
 </head>
 
 <body>
   
   
   
    
  
   
   
   
 
 <!-- Start of first page -->

  <div id="page_giftlist" class="pull-demo-page" data-role="page" >
  <!--   
  <div data-role="panel" id="optpanel" data-display="overlay" data-theme="c">        
  <a style="float:right" href="#my-header" data-rel="close" data-role="button" data-iconpos="notext" data-icon="delete" class="ui-btn-right"></a>
  <h4>Opzioni</h4>    
  <div id="show"> </div> <br/>
  	<label>Budget
       <div id="budget_range" data-role="rangeslider" data-mini="true" data-track-theme="c" data-theme="b">
	        <label class="ui-hidden-accessible" for="range-3a">Rangeslider:</label>
	        <input type="range" name="budget_min" id="budget_min" min="0" max="400" value="">
	        <label for="range-3b">Rangeslider:</label>
        	<input type="range" name="budget_max" id="budget_max" min="0" max="400" value="">
        </div>
     </label>   
    <br/>
    <h3>Suggerimenti</h3> <br/>
    
    <form>
	    <fieldset data-mini="true" data-role="controlgroup">
	        <legend>Vertical:</legend>
	        <input type="checkbox" name="checkbox-v-2a" id="checkbox-v-2a">
	        <label for="checkbox-v-2a">One</label>
	        <input type="checkbox" name="checkbox-v-2b" id="checkbox-v-2b">
	        <label for="checkbox-v-2b">Two</label>
	        <input type="checkbox" name="checkbox-v-2c" id="checkbox-v-2c">
	        <label for="checkbox-v-2c">Three</label>
	    </fieldset>
	</form>
    
  </div> -->    <!-- /panel -->

  
    <header id="my-header" data-role="header" data-position="fixed">
    	<a href="#optpanel" class="ui-btn-left" data-role="button" data-icon="bars" data-iconpos="notext" data-theme="a" data-inline="true">Options</a>
        <h1>Crea il tuo shake</h1>
        <!--  a id="fer" href="#page2" class="ui-btn-right" data-icon="arrow-r">Next</a -->
    </header><!-- /header -->

  <div data-role="content" data-iscroll>
   
   <!--    
    <ul class="ui-icon-alt" style="padding-bottom: 15px" data-role="listview">
      <li><a style="font-size: 14px; color:#366097" href="#page_list_categories">Scegli per categoria</a></li>
    </ul> -->
  
  <!-- add for ajax call -->
 <!--    <div style="padding-top: 5px; padding-bottom: 5px; font-size: 15px; color:#366097 ">I più scelti </div>  
   -->
<!--    <div class="wrapper" id="most_popular"> -->
<!--      <div class="scroller"> -->
    	<!--  content load via ajax --> 
<!--     </div>  -->
<!--    </div>  -->
   
  
  <!-- use scroll with dynamic grid data-iscroll="" -->
  <div id="container"   class="ui-grid-solo" >
  <div class="block description">Pretty row 1. ciao skaljfdlksajhfkljaslkfjdlksajflkseajlkdfjsakljfdlksjalkfdjslkaj</div> 
    <div class="block">  Pretty row 2 </div>
    <div class="block description">Pretty row 1. ciao skaljfdlksajhfkljaslkfjdlksajflkseajlkdfjsakljfdlksjalkfdjslkaj</div>
    <div class="block">  Pretty row 2 </div>
    <div class="block description">Pretty row 1. ciao skaljfdlksajhfkljaslkfjdlksajflkseajlkdfjsakljfdlksjalkfdjslkaj</div>
    <div class="block">  Pretty row 2 </div>
     <div class="block description">Pretty row 1. ciao skaljfdlksajhfkljaslkfjdlksajflkseajlkdfjsakljfdlksjalkfdjslkaj</div> 
    <div class="block">  Pretty row 2 </div>
    <div class="block description">Pretty row 1. ciao skaljfdlksajhfkljaslkfjdlksajflkseajlkdfjsakljfdlksjalkfdjslkaj</div>
    <div class="block">  Pretty row 2 </div>
    <div class="block description">Pretty row 1. ciao skaljfdlksajhfkljaslkfjdlksajflkseajlkdfjsakljfdlksjalkfdjslkaj</div>
    <div class="block">  Pretty row 2 </div>
     <div class="block description">Pretty row 1. ciao skaljfdlksajhfkljaslkfjdlksajflkseajlkdfjsakljfdlksjalkfdjslkaj</div> 
    <div class="block">  Pretty row 2 </div>
    <div class="block description">Pretty row 1. ciao skaljfdlksajhfkljaslkfjdlksajflkseajlkdfjsakljfdlksjalkfdjslkaj</div>
    <div class="block">  Pretty row 2 </div>
    <div class="block description">Pretty row 1. ciao skaljfdlksajhfkljaslkfjdlksajflkseajlkdfjsakljfdlksjalkfdjslkaj</div>
    <div class="block">  Pretty row 2 </div>
     <div class="block description">Pretty row 1. ciao skaljfdlksajhfkljaslkfjdlksajflkseajlkdfjsakljfdlksjalkfdjslkaj</div> 
    <div class="block">  Pretty row 2 </div>
    <div class="block description">Pretty row 1. ciao skaljfdlksajhfkljaslkfjdlksajflkseajlkdfjsakljfdlksjalkfdjslkaj</div>
    <div class="block">  Pretty row 2 </div>
    <div class="block description">Pretty row 1. ciao skaljfdlksajhfkljaslkfjdlksajflkseajlkdfjsakljfdlksjalkfdjslkaj</div>
    <div class="block">  Pretty row 2 </div>
     <div class="block description">Pretty row 1. ciao skaljfdlksajhfkljaslkfjdlksajflkseajlkdfjsakljfdlksjalkfdjslkaj</div> 
    <div class="block">  Pretty row 2 </div>
    <div class="block description">Pretty row 1. ciao skaljfdlksajhfkljaslkfjdlksajflkseajlkdfjsakljfdlksjalkfdjslkaj</div>
    <div class="block">  Pretty row 2 </div>
    <div class="block description">Pretty row 1. ciao skaljfdlksajhfkljaslkfjdlksajflkseajlkdfjsakljfdlksjalkfdjslkaj</div>
    <div class="block">  Pretty row 2 </div>
  
  </div>
  <div class="iscroll-pullup">
      <span class="iscroll-pull-icon"></span>
      <span class="iscroll-pull-label" data-iscroll-loading-text="Custom loading text" data-iscroll-pulled-text="Custom pulled text">Custom reset text</span>
  </div>
  
  
  </div>  <!-- content -->
  

	 
      
      <div data-role="footer" data-position="fixed" class="nav-glyphish-example" data-theme=c>
        <div data-role="navbar" class="nav-glyphish-example" >
          <ul>
            <li><a href="/index.php" id="home" data-icon="custom"><h4>Home</h4></a></li>
            <li><a href="#" id="search" data-icon="custom"><h4>Search</h4></a></li>
            <li><a href="#" id="gift" data-icon="custom">
                <span id="gifts_in_shake" class="ui-li-count" style="left:42px; top:-9px; visibility: hidden "></span>
                <h4>Giftshake</h4>
                </a>
            </li>
            <li><a href="#" id="wishlist" data-icon="custom"><h4>Preferiti</h4></a></li>
          </ul>
        </div>
      </div> <!-- footer -->	


  </div> <!-- end page -->
  

  


  

  
  
 
  <script type="text/javascript">

 // $('#page_giftlist').on('pageload', function() {
  
  $(document).delegate('#page_giftlist', 'pageload', function () {
	       	/*
	           $('#container').BlocksIt({
	       	      numOfCol: 2,
	       	      offsetX: 8,
	       	      offsetY: 8
	       	    });
	          */
	  //        alert(); 	    
	  //         $("#page_giftlist div[data-role=content]").iscrollview("refresh");

  });

  </script>
  
  






<script>
  
  
  /*jslint browser: true, sloppy: true, white: true, nomen: true, plusplus:true, maxerr: 50, indent: 2 */
/*global jQuery:false, iScroll:false */

/*jshint forin:true, noarg:true, noempty:true, eqeqeq:true, bitwise:true, strict:true,
         undef:true, curly:true, browser:true, jquery:true, indent:2, maxerr:50,
         white:false, nomen:false */

//-------------------------------------------------------
// Pull-Up and Pull-Down callbacks for "Pull" page
//-------------------------------------------------------
(function pullPagePullImplementation($) {
  "use strict";


  $.ajax({ url: "get_new_list_url.php",
      type: 'POST',
      async: false,
      data: 'budget_min='+ $('#budget_min').val() + '&budget_max='+ $('#budget_max').val(),
      //async: false,
      
      success: function(data) {
        //alert("Loaded content...");
        //alert(data);
       // $("#most_popular div.scroller").html(data);
         $("#page_giftlist div#container").html(data);

  /*   	
         $('#container').BlocksIt({
     	      numOfCol: 2,
     	      offsetX: 8,
     	      offsetY: 8
     	    });
   */    
     //    $("#page_giftlist div[data-role=content]").iscrollview("refresh");
         
        
        //$("#search-results-list").listview("refresh");
          }, 
      error: function(response, error) {
        //alert("Error: " + response + " : " + error)
        //$("#search-results").html("Unable to load search results.");
      }
  });


  
  var pullDownGeneratedCount = 0,
      pullUpGeneratedCount = 0,
      //listSelector = "div.pull-demo-page ul.ui-listview",
      //lastItemSelector = listSelector + " > li:last-child";
      listSelector = "div.pull-demo-page div#container",
      lastItemSelector = listSelector + " > div:last-child";
    
  /* For this example, I prepend three rows to the list with the pull-down, and append
   * 3 rows to the list with the pull-up. This is only to make a clear illustration that the
   * action has been performed. A pull-down or pull-up might prepend, append, replace or modify
   * the list in some other way, modify some other page content, or may not change the page 
   * at all. It just performs whatever action you'd like to perform when the gesture has been 
   * completed by the user.
   */
  function gotPullDownData(event, data) {
    var i,
        newContent = "";        
    for (i=0; i<3; i+=1) {  // Generate some fake new content
      newContent = "<li>Pulldown-generated row " + (++pullDownGeneratedCount) + "</li>" + newContent;
      }
    $(listSelector).prepend(newContent).listview("refresh");  // Prepend new content and refresh listview
    data.iscrollview.refresh();    // Refresh the iscrollview
    }
  
  function gotPullUpData(event, data) {
	  $.ajax({ url: "get_new_list_url.php",
	        type: 'POST',
	        data: 'budget_min='+ $('#budget_min').val() + '&budget_max='+ $('#budget_max').val(),
	        //async: false,
	        success: function(data) {
	         
             $("#page_giftlist div[data-role=content] div#container").append(data);
            // $("#page_list_item div[data-role=content] ul" ).listview("refresh"); 


             $('#container').BlocksIt({
                numOfCol: 2,
                offsetX: 8,
                offsetY: 8
              });
             $("#page_giftlist div[data-role=content]").iscrollview("refresh");             
           }
          }); // end ajax

	  
    
    var i,
        iscrollview = data.iscrollview,
        newContent = "";
    // for (i=0; i<3; i+=1) { 
      // newContent += "<li>Pullup-generated row " + (++pullUpGeneratedCount) + "</li>";
      // }
    // $(listSelector).append(newContent).listview("refresh");
  
    // The refresh is a bit different for the pull-up, because I want to demonstrate the use
    // of refresh() callbacks. The refresh() function has optional pre and post-refresh callbacks.
    // Here, I use a post-refresh callback to do a timed scroll to the bottom of the list
    // after the new elements are added. The scroller will smoothly scroll to the bottom over
    // a 400mSec period. It's important to use the refresh() callback to insure that the scroll
    // isn't started until the scroller has first been refreshed.
    iscrollview.refresh(null, null,
      $.proxy(function afterRefreshCallback(iscrollview) { 
        this.scrollToElement(lastItemSelector, 400); 
        }, iscrollview) ); 
    }
  
  // This is the callback that is called when the user has completed the pull-down gesture.
  // Your code should initiate retrieving data from a server, local database, etc.
  // Typically, you will call some function like jQuery.ajax() that will make a callback
  // once data has been retrieved.
  //
  // For demo, we just use timeout to simulate the time required to complete the operation.
  function onPullDown (event, data) { 
    setTimeout(function fakeRetrieveDataTimeout() {
      gotPullDownData(event, data);
      }, 
      1500); 
    }    

  // Called when the user completes the pull-up gesture.
  function onPullUp (event, data) { 
    
    
    setTimeout(function fakeRetrieveDataTimeout() {
      gotPullUpData(event, data);
      }, 
      1500); 
    }    
  
  // Set-up jQuery event callbacks
  $(document).delegate("div.pull-demo-page", "pageinit", 
    function bindPullPagePullCallbacks(event) {
      $(".iscroll-wrapper", this).bind( {
      iscroll_onpulldown : onPullDown,
      iscroll_onpullup   : onPullUp
      } );
    } );  

  }(jQuery));


 </script>



  
  
  


  
 </body>  
</html>